package com.sevens.service.impl;



import java.sql.Timestamp;
import java.util.List;

import com.sevens.dao.UserDao;
import com.sevens.service.UserService;
import com.sevens.vo.News;
import com.sevens.vo.User;

public class UserServiceImpl implements UserService {
	
	private UserDao userDao;
	

	public UserDao getUserDao() {
		return userDao;
	}


	public void setUserDao(UserDao userDao) {
		this.userDao = userDao;
	}


	
	
	public User checkUser(String username, String password) {
		System.out.println("login at service layer");
		User user = this.userDao.checkUser(username, password);
		return user;
	}


	@Override
	public boolean saveUser(User user) {
		// TODO Auto-generated method stub

		if(userDao.saveUser(user)!= null)
			return true;
		else
			return false;
	}


	@Override
	public String queryPasswordByUseremail(String useremail) {
		// TODO Auto-generated method stub
		String password=this.userDao.queryPasswordByUseremail(useremail);
		return password;
		
	}


	@Override
	public boolean editUser(User user,String repassword) {
		// TODO Auto-generated method stub
		boolean bool = this.userDao.editUser(user,repassword);
		return bool;
	}


	@Override
	public List<User> queryUser(User user) {
		// TODO Auto-generated method stub
		return this.userDao.queryUser(user);
	}





	@Override
	public boolean edit(User user) {
		// TODO Auto-generated method stub
		boolean bool = this.userDao.edit(user);
		return bool;
	}


	@Override
	public boolean deleteUserById(int checkedUserId) {
		// TODO Auto-generated method stub
		boolean bool = this.userDao.deleteUser(checkedUserId);
		return bool;
	}


	@Override
	public User queryUserById(int checkedUserId) {
		// TODO Auto-generated method stub
		User user=this.userDao.queryUserById(checkedUserId);
		return user;
	}


	@Override
	public List<User> queryAllUser() {
		// TODO Auto-generated method stub
		List<User> list = this.userDao.queryAllUser();
		return list;
	}

	public String queryRoles(int userId){
		return userDao.queryRoles(userId);
	}
	public String updateUserRole(int userId,String roleIds)
	{
		return userDao.updateUserRole(userId, roleIds);
	}


	public User queryUserByName(String name) {
		// TODO Auto-generated method stub
		User user = this.userDao.queryUserByName(name);
		return user;
	}
	public String queryPermissions(int userId)
	{
		return userDao.queryPermissions(userId);
	}
}
